package org.ch00.test05;

import java.util.Random;

/*
 *
 *@author XCH
 *@date 2025 - 03 - 05 - 09:02
 *
 */
public class Thief {
    public void steal(Door door) {
        System.out.println("小偷准备偷窃");
        System.out.println("-------------------------------------");
        Random random = new Random();
        int action = random.nextInt(2) + 1;
        if (door instanceof Ring securityDoor && random.nextBoolean()) {
            securityDoor.ring(); // 强制响铃
        }
        if (action == 1) {
            System.out.println("偷窃失败");
            return;
        }







        door.open();
        System.out.println("偷窃成功");

    }
}

